<?php
//include Header
include("header.php");
?>
<?php
$id=$_REQUEST["id"];
$query = mysql_query("	SELECT productnaam, image, cat1, cat2,cat3,aanbieding, description, prijs 
						FROM producten 
						INNER JOIN productprijs
						ON productprijs.productnummer=producten.productnummer
						WHERE producten.productnummer = $id",$server);

while($row = mysql_fetch_array($query))
	{
		$titel=$row[productnaam];
		$cat1=$row[cat1];
		$cat2=$row[cat2];
		$cat3=$row[cat3];
		$plaatje=$row[image];
		$description=$row[description];
		$prijs=$row[prijs];
	}
$resultt = mysql_query("SELECT prijs  
						FROM productprijs
						WHERE productnummer=$id
						order by datum",$server);
$inlist = "";
$tmp = 0;
$highest = 0;
while($row = mysql_fetch_array($resultt)){
	$prijstmp = sprintf("%01.2f",($row['prijs']/100));
	if($highest < $prijstmp){
		$highest = $prijstmp;
	}
	if($tmp == 1){
		$inlist .= ",";
	}
	$inlist .= "$prijstmp";
	$tmp = 1;
}
echo "$inlist<div>";
echo 	"<table border=\"0\" id=\"productTable\" width=\"100%\">
		<thead>
			<tr>
			<TD colspan=\"5\"><br></TD>	
			</tr>
			<tr>
			<TD colspan=\"5\"><H1>".$titel."</H1></TD>
			</tr>
			<tr>
			<TD colspan=\"5\"><br></TD>	
			</tr>
			<tr>
			<TD colspan=\"5\"><H3>(".$cat1."&nbsp;".$cat2."&nbsp;".$cat3.")</H3></TD>
			</tr>
		</thead>
		<tbody>
		<tr>
			<TD colspan=\"5\"><br></TD>	
		</tr>
		<tr>
		<td colspan=\"2\" width=\"20%\" ></td>
		<TD  width=\"20%\" ><a href='/images/producten/normal_$plaatje' TARGET='new'><img src=\"/images/producten/thumb_" .$plaatje. "\" TITLE='Klik op afbeelding om te vergroten.'/></a></TD>	
		<TD  width=\"20%\" ><font color=red><h1>&euro; " .sprintf("%01.2f",($prijs/100)) ."</h1></font></TD>
		<TD  width=\"20%\"><A HREF=\"mandje.php?id=".$id."\"><IMG SRC=\"images/button_bestellen.gif\"></A>";
		$beheerderq = mysql_query("select beheerder from klanten where klantnummer = " . $_SESSION['klantnummer'] > "",$server);
		$beheerder = 0;
		while($beheerderrow = mysql_fetch_array($beheerderq)){
			$beheerder = $beheerderrow['beheerder'];
		}
		if(beheerder){
			echo "<br /><A HREF=\"beheer/product.php?id=".$id."\"><IMG SRC=\"images/button_beheren.gif\"></A>";
		}
			
		echo "
		</TD>
		</tr>
		<tr>
			<TD colspan=\"5\"><br></TD>	
			</tr>
		<tr>
		<td  width=\"20%\" ></td>
		<td colspan=\"3\" width=\"300\">".$description."</td>
		<td></td>
		</tr>
		<tr>
			<TD colspan=\"5\"><br></TD>	
			</tr>
		<tr>
		<tr>
			<TD ALIGN=\"center\" colspan=\"5\"><H2>Details</H2></TD>	
			</tr>
			<tr>
			<TD colspan=\"5\"><br></TD>	
			</tr>
		<tr>
		<tr>
		</tbody>
		<tfoot>

		</tfoot>
		</table>";
echo "</div>";

?>
<?php
echo "<div>";
echo 	"<table border=\"0\" id=\"productTable\" width=\"100%\">
		<thead>
			<tr>
			</tr>
		</thead>
		<tbody>";
$query = mysql_query("select * from productinfo where productnummer = $id",$server);
$lastname2 = "";
while($row = mysql_fetch_array($query)){
	$name2 = $row['name2'];
	$name3 = $row['name3'];
	$value = $row['value'];
	echo "
	<tr>
	<td width=\"25%\"></td>
		<th ALIGN=\"right\">";
			if($name2 != $lastname2){
				echo "$name2 &nbsp;" ;
			};
			
			echo "
		</th>";
			if($name2 == $name3){
				echo "
					<td ALIGN=\"left\" width=\"25%\">
						&nbsp;&nbsp; $value 
					</td>
					";
			} 
			else {
				echo "
					<td ALIGN=\"left\" width=\"25%\">
						&nbsp;&nbsp; $name3
					</td>
					<td ALIGN=\"left\" width=\"25%\">
						&nbsp; &nbsp; $value
					</td>";
			}
		echo "
		<td width=\"25%\"></td>
	</tr>";
	$lastname2 = $name2;
};
echo "</tbody> <tfoot><tr></tr></tfoot></table><img src=\"http://chart.apis.google.com/chart?chxr=0,0,$highest
																							&chm=B,A6A6DD80,0,0,0
																							&chxt=y
																							&chs=300x225
																							&cht=lc
																							&chco=A6A6DD
																							&chds=0,345.9
																							&chd=t:$inlist
																							&chtt=Prijs+Verloop
																							&chls=3,4,0
																							&chg=14.3,-1,1,1
																							
																							\"width=\"300\" height=\"225\" alt=\"Prijs Verloop\" />";
echo "</div>";

include("gerelateerdeProducten.php");
?>
<?php
// include registratie bekeken product
include("registreerbekekenproduct.php");

//include footer
include("footer.php");
?>
